package org.desktop.web.shared.domain.entities;

import java.io.Serializable;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;


/**
 * The persistent class for the SUB_FUNCTIONS database table.
 * 
 */
@Entity
@Table(name="SUB_FUNCTIONS")
@NamedQuery(name="SubFunction.findAll", query="SELECT s FROM SubFunction s")
@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonIgnoreProperties(value={"roles"})
@JsonInclude(Include.NON_NULL)
public class SubFunction implements Serializable, com.google.gwt.user.client.rpc.IsSerializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private String descSubFunctions;
	
	
	@JsonProperty("idFunctions")
	private Function function;
	private List<Role> roles;

	public SubFunction() {
	}


	@Id
	@Column(unique=true, nullable=false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Column(name="DESC_SUB_FUNCTIONS", length=100)
	public String getDescSubFunctions() {
		return this.descSubFunctions;
	}

	public void setDescSubFunctions(String descSubFunctions) {
		this.descSubFunctions = descSubFunctions;
	}


	//bi-directional many-to-one association to Function
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ID_FUNCTIONS", nullable=false)
	public Function getFunction() {
		return this.function;
	}

	public void setFunction(Function function) {
		this.function = function;
	}


	//bi-directional many-to-many association to Role
	@ManyToMany
	@JoinTable(
		name="SUB_FUNCTIONS_ROLES"
		, joinColumns={
			@JoinColumn(name="ID_SUB_FUNCTION", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="ID_ROLE", nullable=false)
			}
		)
	public List<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

}